extends Camera2D

@onready var player = get_node("%Player")
enum CameraState {
	PANNING,
	FOLLOW
}
@export var Camera: CameraState

func _process(delta):
	match Camera:
		CameraState.PANNING:
			camera_panning()
		CameraState.FOLLOW:
			camera_follow()


func camera_panning():
	anchor_mode = Camera2D.ANCHOR_MODE_FIXED_TOP_LEFT
	
	position = player.position
	var x = floor(position.x / 320) * 320
	var y = floor(position.y / 180) * 180
	
	position = Vector2(x, y)
	
	var tween := create_tween().set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_IN_OUT)
	tween.tween_property(self, "position", Vector2(x, y), 0.04) 


func camera_follow():
	anchor_mode = Camera2D.ANCHOR_MODE_DRAG_CENTER
	position = player.position
